<?php
class Cronjob extends AppModel{
	var $name = 'Cronjob';
	var $belongsTo = 'Survey';
	
	function setSurveyAlarms($alarms, $survey){
		foreach($alarms as $i=>$alarm){
			$survey['Cronjob'][$i]['action'] = 0;
			$survey['Cronjob'][$i]['mon'] = $alarm['month'];
			$survey['Cronjob'][$i]['hour'] = $alarm['hour'];
			$survey['Cronjob'][$i]['min'] = $alarm['minute'];
			if($alarm['day']=='*'){
				$survey['Cronjob'][$i]['dom'] = "*";
				$survey['Cronjob'][$i]['dow'] = "*";
			
			}
			elseif(((int)$alarm['day']) < 7){
				$survey['Cronjob'][$i]['dom'] = "*";
				$survey['Cronjob'][$i]['dow'] = $alarm['day'];
			}
			else{
				$survey['Cronjob'][$i]['dom'] = $alarm['day']-6;
				$survey['Cronjob'][$i]['dow'] = "*";
			}
		}
		return $survey;
	}
}

?>
